/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */

package com.ykht.proj.coupon.controller;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ykht.proj.common.core.util.R;
import com.ykht.proj.common.log.annotation.SysLog;
import com.ykht.proj.coupon.entity.FxCmsRecommend;
import com.ykht.proj.coupon.service.FxCmsRecommendService;
import com.ykht.proj.coupon.vo.FxCmsRecommendVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 资讯推荐表
 *
 * @author proj code generator
 * @date 2021-07-07 16:20:00
 */
@RestController
@AllArgsConstructor
@RequestMapping("/fxcmsrecommend" )
@Api(value = "fxcmsrecommend", tags = "资讯推荐表管理")
@Slf4j
public class FxCmsRecommendController {

    private final  FxCmsRecommendService fxCmsRecommendService;

    /**
     * 资讯推荐表 分页查询
     * @param page 分页对象
     * @param fxCmsRecommendVo 资讯推荐表
     * @return
     */
    @ApiOperation(value = "资讯推荐表 分页查询", notes = "资讯推荐表 分页查询")
    @GetMapping("/page" )
    public R<IPage<FxCmsRecommendVo>> getFxCmsRecommendPage(Page page, FxCmsRecommendVo fxCmsRecommendVo) {
		log.info("->资讯推荐表 分页查询:{}", JSONUtil.toJsonStr(fxCmsRecommendVo));
		IPage<FxCmsRecommendVo> iPage = fxCmsRecommendService.getFxCmsRecommendPage(page, fxCmsRecommendVo);
        return R.ok(iPage);
    }


    /**
     * 通过id查询资讯推荐表
     * @param id id
     * @return R
    @PreAuthorize("@pms.hasPermission('coupon_fxcmsrecommend_view')" )
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(fxCmsRecommendService.getById(id));
    }

    /**
     * 新增资讯推荐表
     * @param fxCmsRecommend 资讯推荐表
     * @return R
     */
    @ApiOperation(value = "新增资讯推荐表", notes = "新增资讯推荐表")
    @SysLog("新增资讯推荐表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('coupon_fxcmsrecommend_add')" )
    public R save(@RequestBody FxCmsRecommend fxCmsRecommend) {
        return R.ok(fxCmsRecommendService.save(fxCmsRecommend));
    }

    /**
     * 修改资讯推荐表
     * @param fxCmsRecommend 资讯推荐表
    @PreAuthorize("@pms.hasPermission('coupon_fxcmsrecommend_edit')" )
     * @return R
     */
    @ApiOperation(value = "修改资讯推荐表", notes = "修改资讯推荐表")
    @SysLog("修改资讯推荐表" )
    @PutMapping
    public R updateById(@RequestBody FxCmsRecommend fxCmsRecommend) {
        return R.ok(fxCmsRecommendService.updateById(fxCmsRecommend));
    }

    /**
     * 通过id删除资讯推荐表
     * @param id id
     * @return R
    @PreAuthorize("@pms.hasPermission('coupon_fxcmsrecommend_del')" )
     */
    @ApiOperation(value = "通过id删除资讯推荐表", notes = "通过id删除资讯推荐表")
    @SysLog("通过id删除资讯推荐表" )
    @DeleteMapping("/{id}" )
    public R removeById(@PathVariable Long id) {
        return R.ok(fxCmsRecommendService.removeById(id));
    }

}
